import { createApp } from 'vue'
import App from './App.vue'
// store
import { createPinia } from 'pinia'
import { useMainStore } from './store/main'
// router
import router from './router'
// 引入全局样式
import './assets/style/reset.css'
import './assets/style/main.css'
// 全局引入的naive-ui组件
import naive from './plugins/naive-ui'
// 自定义的全局组件
import SuperTable from './components/SuperTable.vue'
import FilterItem from './components/FilterItem.vue'
// 缓存key
import { themeCacheKey } from './config/cacheKey'

const app = createApp(App)
app.use(createPinia())
app.use(router)
app.use(naive)
app.component('super-table', SuperTable)
app.component('filter-item', FilterItem)

const mainStore = useMainStore()
// 如果缓存中有主题配置，初始化主题为缓存主题
const cacheTheme = localStorage.getItem(themeCacheKey)
cacheTheme && mainStore.setTheme(cacheTheme)

app.mount('#app')
